package com;

import com.fz.entity.User;
import com.fz.mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by webrx on 2017-08-31.
 */
public class Demo {

    @Test
    public void tt(){
        InputStream im = null;
        try {
            im = Resources.getResourceAsStream("mybatis-conf.xml");
        } catch (IOException e) {
            e.printStackTrace();
        }
        SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(im);
        SqlSession ss = sf.openSession();
        UserMapper umdao = ss.getMapper(UserMapper.class);
        //User u = new User();
        //u.setUserName("张三丰");
        //u.setAge(28);
        umdao.save("李勇",18);
        umdao.save("张三",28);
        umdao.save("李勇2",38);
        umdao.save("李勇3",48);
        //umdao.insert(u);

        ss.commit();
    }
}
